package com.fan.base;

import java.io.Serializable;

/**
 * controller接口返回对象
 * 
 * @author kffansensen
 */
public class WebResult<T> implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	public WebResult() {
		super();
	}
	public  WebResult(T t) {
		this.result = t;
	}
	/**
	 * 接口处理状态，参考httpstatus,200成功，999失败
	 */
	private String status = StatusEnum.SUCCESS.getCode();
	/**
	 * 错误信息
	 */
	private String errorMsg;
	/**
	 * 返回信息
	 */
	private T result;

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public String getErrorMsg() {
		return errorMsg;
	}

	public void setErrorMsg(String errorMsg) {
		this.errorMsg = errorMsg;
		this.status = StatusEnum.FAILED.getCode();
	}

	public T getResult() {
		return result;
	}

	public void setResult(T result) {
		this.result = result;
	}

	public enum StatusEnum {
		SUCCESS("200", "成功"), FAILED("999", "失败");

		private StatusEnum(String code, String msg) {
			this.code = code;
			this.msg = msg;
		}

		private String code;
		private String msg;
		public String getCode() {
			return code;
		}
		public void setCode(String code) {
			this.code = code;
		}
		public String getMsg() {
			return msg;
		}
		public void setMsg(String msg) {
			this.msg = msg;
		}
	}
}
